package io.renren.modules.sys.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.sys.dao.JxLaboratoryDao;
import io.renren.modules.sys.entity.JxLaboratoryEntity;
import io.renren.modules.sys.service.JxLaboratoryService;


@Service("jxLaboratoryService")
public class JxLaboratoryServiceImpl extends ServiceImpl<JxLaboratoryDao, JxLaboratoryEntity> implements JxLaboratoryService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<JxLaboratoryEntity> page = this.page(
                new Query<JxLaboratoryEntity>().getPage(params),
                new QueryWrapper<JxLaboratoryEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public PageUtils getAllWithPage(Map<String, Object> params) {
        PageHelper.startPage(Integer.parseInt(params.get("page").toString()),Integer.parseInt(params.get("limit").toString()));
        List<JxLaboratoryEntity> list = this.baseMapper.getAllWithPage(params);
        PageInfo<JxLaboratoryEntity> pageInfo = new PageInfo<JxLaboratoryEntity>(list);
        return new PageUtils(list,(int)pageInfo.getTotal(),pageInfo.getPageSize(),pageInfo.getPageNum());
    }

    @Override
    public List<JxLaboratoryEntity> getAllLaboratory() {
        return this.baseMapper.getAllWithPage(new HashMap<String, Object>());
    }
}
